using UnityEngine;

[CreateAssetMenu(fileName = "SoundEffect_", menuName = "游戏SO文件/声音/音效文件")]
public class SoundEffectSO : ScriptableObject
{
    #region Header SOUND EFFECT DETAILS

    [Space(10)]
    [Header("音效细节")]

    #endregion

    #region Tooltip

    [Tooltip("声音效果的名称")]

    #endregion

    public string soundEffectName;

    #region Tooltip

    [Tooltip("声音效果的预制件")]

    #endregion

    public GameObject soundPrefab;

    #region Tooltip

    [Tooltip("声音效果的音频剪辑")]

    #endregion

    public AudioClip soundEffectClip;

    #region Tooltip

    [Tooltip("声音效果的最小音高变化。 将在最小值和最大值之间生成随机的音高变化。 随机的音高变化使音效听起来更自然.")]

    #endregion

    [Range(0.1f, 1.5f)]
    public float soundEffectPitchRandomVariationMin = 0.8f;

    #region Tooltip

    [Tooltip("声音效果的最大音高变化。 将在最小值和最大值之间生成随机的音高变化。 随机的音高变化使音效听起来更自然.")]

    #endregion

    [Range(0.1f, 1.5f)]
    public float soundEffectPitchRandomVariationMax = 1.2f;

    #region Tooltip

    [Tooltip("音效音量.")]

    #endregion

    [Range(0f, 1f)]
    public float soundEffectVolume = 1f;

    #region Validation

#if UNITY_EDITOR
    private void OnValidate()
    {
        HelperUtilities.ValidateCheckEmptyString(this, nameof(soundEffectName), soundEffectName);
        HelperUtilities.ValidateCheckNullValue(this, nameof(soundPrefab), soundPrefab);
        HelperUtilities.ValidateCheckNullValue(this, nameof(soundEffectClip), soundEffectClip);
        HelperUtilities.ValidateCheckPositiveRange(this, nameof(soundEffectPitchRandomVariationMin),
            soundEffectPitchRandomVariationMin, nameof(soundEffectPitchRandomVariationMax),
            soundEffectPitchRandomVariationMax, false);
        HelperUtilities.ValidateCheckPositiveValue(this, nameof(soundEffectVolume), soundEffectVolume, true);
    }
#endif

    #endregion
}